package com.sxl.config;

import com.auth0.jwt.JWT;

import javax.servlet.http.HttpServletRequest;

/**
 * @author shkstart
 * @create 2022-04-01 下午 3:46
 */
public class AuthUtils {
    public static Integer getUserId(HttpServletRequest req) {
        String token = req.getHeader("Authorization");
        String userId = JWT.decode(token).getAudience().get(0);
        return Integer.parseInt(userId);
    }
}
